<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>酷妈妈商城</title>
<script type="text/javascript">
	
</script>
<style type="text/css">
table {
	border: 1px solid #eee;
}

.line {
	border-top: 1px solid #eee;
}
</style>
</head>
<body>
	<h1>添加订单</h1>
	<h4 style="color: red;">${msg}</h4>
	<c:if test="${not empty cart}">
		<table class="line" width="90%">
			<tr>
				<th>编号</th>
				<th>名称</th>
				<th>单价</th>
				<th>购买数量</th>
				<th>单项总价</th>
			</tr>
			<c:set var="total" value="0" scope="page"></c:set>
			<c:forEach var="entry" items="${cart}">
				<tr>
					<td class="line">${entry.key.id }</td>
					<td class="line">${entry.key.name }</td>
					<td class="line">${entry.key.price }</td>
					<td class="line">${entry.value }</td>
					<td class="line">${entry.value * entry.key.price }</td>
					<c:set var="total" value="${entry.value * entry.key.price + total}"
						scope="page"></c:set>
				</tr>
			</c:forEach>
			<tr>
				<td colspan="5" align="right" class="line">合计金额：${total}</td>
			</tr>
		</table>
		<h2>填写收货人信息</h2>
		<form action="<%=basePath %>addOrders"
			method="post">
			收货人信息：
			<textarea rows="6" cols="80" name="receiverinfo"></textarea>
			<input type="submit" value="生成订单">
		</form>
	</c:if>
</body>
</html>